﻿

namespace LxCFD
{
    public partial class ZoneCFDFields
    {
        protected TurbulenceModelkw kw;
        public void CreateFields_kw(bool isSupportByParent)
        {
            bool advice = isSupportByParent;
            if(advice)
            {
                if (kw == null)
                {
                    kw = new TurbulenceModelkw();
                    kw.CheckCreate(Zone);
                }
                AppRes.SolveCenter.TurbulenceGroup.kwZoneTempStore.Add(kw);
                AppRes.SolveCenter.InitializeGroup.Initialization_Normal6.Add(kw);
            }
            else
            {
                kw = null;
            }
        }

        public void SetParameter_kw()
        {
            kw.SetZone_part1(Velocity, GammaCommon, Density, WallDistance);
            kw.SetZone_part2(Value1Const.Double0, 0.01, 0.8, ConvectionSchemes.FirstOrderUpwind, 1e-10, new Value1Const.Double(0), 0.1, 0.8, ConvectionSchemes.FirstOrderUpwind, 1e-10);
            if (AppRes.SolveCenter.IsTransient)
            {
                kw.k.SetZone_TransTerm(true, Value1Const.Double1, Density);
                kw.w.SetZone_TransTerm(true, Value1Const.Double1, Density);
                AppRes.SolveCenter.InitializeGroup.Initialization_Transient9.Add(kw.k.TransData);
                AppRes.SolveCenter.InitializeGroup.Initialization_Transient9.Add(kw.w.TransData);
            }
            else
            {
                kw.k.SetZone_TransTerm(false, null, null);
                kw.w.SetZone_TransTerm(false, null, null);
            }
            foreach (var t in Zone.BoundThreads)
            {
                switch (t.BoundaryType)
                {
                    case BoundaryTypes.FluidWall:
                    case BoundaryTypes.Symmetry:
                        kw.SetBound_WallOrSymmetry(t);
                        break;
                    case BoundaryTypes.VelocityInlet:
                    case BoundaryTypes.PressureInOut:
                        kw.SetBound_Flow(0.01, 0.1, t);
                        break;
                    default:
                        LxConsole.Error("未知边界类型");
                        break;
                }
            }
        }
    }
}


//SolverControl.SIMPLEGroup.Addkew(zone, zone.AMGSolver, kw);
